<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="/static/bootstrap-3.3.7-dist/css/bootstrap.css">
    <script src="/home/js/jquery-3.3.1.min.js"></script>
    <title>Document</title>
    <style>
        tr,th,td{
            border: 1px blue solid;
            width: 200px;
            height: 25px;
            text-align: center;
            line-height:25px;
            font-size: 18px;
        }
    </style>
</head>
<body>
    <p>PHP原生输出</p>
    <table>
            <tr>
                <th>id</th>
                <th>user</th>
                <th>pwd</th>
                <th>time</th>
            </tr>
        <!-- 数组遍历输出 -->
        {foreach name="rows" item="row"}
            <!-- 关联数组遍历输出
            {foreach name="row" item="val" key="index"}
                {$val}
            {/foreach} -->
            <tr>
                <td>{$row['ID']}</td>
                <td>{$row['user']}</td>
                <td>{$row['password']}</td>
                <td>{$row['time']}</td>
            </tr>
        {/foreach}
    </table>
    {$link}
    <?php 
        //var_dump($rows);
    ?>
    <hr />
    <p>ajax异步数据输出</p>
    <table id="table">
        
    </table>
    <div id="link"></div>
   
    <script>
        function ajaxThinkPage(page){
            $.ajax({
                type:'post',
                url:"{:url('home/Home/ajaxThinkPage')}",
                dataType:"json",
                data:{page:page},
                success:function(data){
                    // console.log(data);
                    $('#link').html(data.link);
                    // $('#table').append(data.link);
                    var rows = data.rows.data;
                    var html = '<tr><th>id</th><th>user</th><th>pwd</th><th>time</th></tr>';
                    $.each(rows,function(i){
                        html += "<tr><td>"+rows[i].ID+"</td><td>"+rows[i].user+"</td><td>"+rows[i].password+"</td><td>"+rows[i].time+"</td></tr>";
                    })
                    $('#table').html(html);
                }
            })
        }   
        ajaxThinkPage(1);             
    </script>
</body>
</html>